<?php

namespace Push\Exceptions;

class RequestException extends IosPushException
{
    public static $errorMap = [
        0 => 'No errors encountered',
        1 => 'Processing error',
        2 => 'Missing device token',
        3 => 'Missing topic',
        4 => 'Missing payload',
        5 => 'Invalid token size',
        6 => 'Invalid topic size',
        7 => 'Invalid payload size',
        8 => 'Invalid token 255 - None (unknown)'
    ];

    public function __construct($code = 0, Throwable $previous = null)
    {
        if (!in_array($code, array_keys(static::$errorMap))) {
            $code = 1;
        }
        parent::__construct(static::$errorMap[$code], $code, $previous);
    }
}
